﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MensUnoShop.Models
{
    public class Product
    {
        private Guid _pdguid;
        private Guid _pdmkguid;
        private int _titletagid;
        private string _title;
        private string _picbig;
        private string _picsmall;
        private bool _pdstatus;
        private List<Specification> _spec;
        private DBMarket _repository;
        
        public Guid PDGUID { set{_pdguid=value;} get{return _pdguid;} }
        public Guid PDMKGUID { set { _pdmkguid = value; } get { return _pdmkguid; } }
        public int TITLETAGID { set{_titletagid=value;} get{return _titletagid;} }
        public string TITLE { set{_title=value;} get{return _title;} }
        public string PICBIG { set{_picbig=value;} get{return _picbig;} }
        public string PICSMALL { set{_picsmall=value;} get{return _picsmall;} }
        public bool PDSTATUS { set { _pdstatus = value; } get { return _pdstatus; } }
        public List<Specification> SPEC { set { _spec = value; } get { return _spec; } }

        public void GetSpecification()
        {
            setRepository();
            _spec = _repository.GetProductSpec(_pdguid);
        }

        private void setRepository()
        {
            if (_repository == null)
                _repository = new DBMarket();
        }

        public void Update()
        {
            setRepository();
            _repository.UpdateProduct(this);
        }

        //更新商品標籤
        public void Update(int pdtitletagid)
        {
            setRepository();
            _repository.UpdateProduct(this, pdtitletagid);
        }

        public void UpdatePDStatus()
        {
            setRepository();
            _repository.UpdateProductStatus(this);
        }
    }
}